Package

Source Code of PushCounter

import java.awt.Color;
import java.awt.Dimension;

import javax.swing.JColorChooser;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;

public class PushCounter {

  public static void main(String[] args) {
    JFrame frame = new JFrame("Display Color");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JPanel colorPanel = new JPanel();
    colorPanel.setBackground(Color.white);
    colorPanel.setPreferredSize(new Dimension(300, 100));
    frame.getContentPane().add(colorPanel);
    frame.pack();
    frame.show();
    Color shade = Color.white;
    int again;
    do {
      shade = JColorChooser.showDialog(frame, "Pick a Color!", shade);
      colorPanel.setBackground(shade);
      again = JOptionPane.showConfirmDialog(null, "Change color again?");
    } while (again == JOptionPane.YES_OPTION);
  }

}
TOP

Related Classes of PushCounter

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.